home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DTP / DTP_TEX / 3239.ZIP / DVIMTP.ZIP / F20OPEN.H < prev    next >
C/C++ Source or Header  |  1987-11-01  |  2KB  |  78 lines

  1. /* -*-C-*- f20open.h */
  2. /*-->f20open*/
  3. /**********************************************************************/
  4. /****************************** f20open *******************************/
  5. /**********************************************************************/
  6.  
  7. #if    OS_TOPS20
  8. FILE*
  9. f20open(filename,mode)
  10. char *filename;
  11. char *mode;
  12.  
  13. /***********************************************************************
  14. Input files are opened in bytesize 8, since this is what is expected for
  15. dvi files.  Output files are opened in bytesize BYTE_SIZE, which will be
  16. 7 or 8, depending on the output device.
  17. ***********************************************************************/
  18. {
  19.     int fp;
  20.  
  21.     if (g_dolog && (g_logfp != (FILE *)NULL))
  22.     {
  23.     (void)fprintf(g_logfp,"%%Opening %d-bit file %s for mode %s",
  24.         ((mode[0] == 'r') ? 8 : BYTE_SIZE),filename,mode);
  25.     NEWLINE(g_logfp);
  26.     }
  27.  
  28.     /* Copy file in bytesize BYTE_SIZE with binary flag set to prevent
  29.        CRLF <--> LF mapping; the "rb" or "wb" flag is not sufficient for
  30.        this because PCC-20 maintains two places internally
  31.        where the binary flag is set, and both are used!  */
  32.  
  33.     if (mode[0] == 'r')
  34.  
  35. #if    KCC_20
  36.         return(fopen(filename,RB_OPEN));
  37. #endif /* KCC_20 */
  38.  
  39. #if    PCC_20
  40.     if ((fp = open(filename,FATT_RDONLY | FATT_SETSIZE | FATT_BINARY,
  41.         8)) >= 0)
  42.         return(fdopen(fp,RB_OPEN));
  43.     else
  44.         return((FILE*)NULL);
  45. #endif /* PCC_20 */
  46.  
  47.     else if (mode[0] == 'w')
  48.  
  49. #if    KCC_20
  50. #if    BYTE_SIZE == 7
  51.         return (fopen(filename,"wb7"));
  52. #else
  53. #if    BYTE_SIZE == 8
  54.         return (fopen(filename,"wb8"));
  55. #else
  56.     fatal("Illegal bytesize set for KCC-20 implementation");
  57. #endif
  58. #endif
  59. #endif /* KCC_20 */
  60.  
  61. #if    PCC_20
  62.     if ((fp = open(filename, FATT_WRONLY | FATT_SETSIZE | FATT_BINARY,
  63.         BYTE_SIZE)) >= 0)
  64.         return(fdopen(fp,WB_OPEN));
  65.     else
  66.         return((FILE*)NULL);
  67. #endif /* PCC_20 */
  68.  
  69.     else
  70.     {
  71.     (void)sprintf(message,
  72.         "f20open does not understand open mode %s for file %s",
  73.         mode,filename);
  74.     fatal(message);
  75.     }
  76. }
  77. #endif /* OS_TOPS20 */
  78.